package org.deng.learn.basic.nio;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.Scanner;

/**
 * @Project
 * @Module
 * @JDK_Vserion 1.8
 * @Author DengLibin
 * @Email dlb@smarthse.cn
 * @Desc
 * @since 2019/9/23 0023 11:12
 */
public class BIOClient {

    public static void main(String[] args) throws IOException {
        Socket socket = new Socket();
        socket.connect(new InetSocketAddress(12232));
        OutputStream outputStream = socket.getOutputStream();
        String text = new Scanner(System.in).nextLine();
        outputStream.write(text.getBytes());

        InputStream inputStream = socket.getInputStream();
        byte[] buf = new byte[1024];
        inputStream.read(buf);
        System.out.println(new String(buf));
    }
}
